#pragma once 
#include <iostream>
#include <pthread.h>

class Task 
{
  private:
    int x;
    int y;
    char op;
  public:
    Task(){}  //无参构造一定要有
    Task(int _x, int _y, int _op)
      :x(_x)
       ,y(_y)
       ,op(_op)
    {}
    void run()
    {
      int z = -1;
      switch(op)
      {
        case '+':
          z = x + y;
          break;
        case '-':
          z = x - y;
          break;
        case '*':
          z = x * y;
          break;
        case '/':
          if(0 != y)  z = x / y;
          else std::cout << "Warning: div zero!" << std::endl;
          break;
        case '%':
          if(0 != y)  z = x % y;
          else std::cout << "Warning: div zero!" << std::endl;
          break;
        default:
          std::cout << "error!" << std::endl;
          break;
      }
      std::cout << "thread[" << pthread_self() << "]: " << x << op << y << "=" << z << std::endl;
    }
    ~Task(){};
};
